/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package monitor;

import beans.OperationsRemote;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author migueldiaz
 */
public class Monitor {
    


    public static void main(String[] args) throws UnknownHostException, IOException, NamingException {
        
        

    
        String machinesEJBip = "5.185.48.148";
       //Daemon daemon = new Daemon();
        Properties properties = new Properties();
        properties.put(Context.INITIAL_CONTEXT_FACTORY,
                "com.sun.enterprise.naming.SerialInitContextFactory");
        properties.setProperty("org.omg.CORBA.ORBInitialHost", machinesEJBip);
        properties.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

        InitialContext context = new InitialContext(properties);
        OperationsRemote operations = (OperationsRemote) context.lookup("beans.OperationsRemote");

        List<String>avalaibleMachines = operations.ipsList();
        
       System.out.println(avalaibleMachines.isEmpty());
       
//        
//        Thread th=new 
//        
//
//
//
//        while (true) {
//
//            System.out.println(daemon.ping("168.176.37.185"));
//            
//
//            Thread.sleep(daemon.getTIME_OUT());
//        }
    }
}
